<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Model;

class VideoCategory extends Model
{
	use HasDateTimeFormatter;
    protected $table = 'video_categories';

    public $fillable = [
        'name','img','state','sort'
    ];
    
    //追加自定义字段，未解密的标题
    protected $appends = ['c_name'];
    public function getCNameAttribute()
    {
        return xor_enc($this->name);
    }

    //局部作用域--是否显示
    public function scopeShow($query){
        return $query->where('state', 1);
    }

    public function getNameAttribute($value){
        return xor_enc($value);
    }

    public function setNameAttribute($value){
        $this->attributes['name'] = xor_enc($value);
    }
}
